﻿@model Infinity.BusinessLayer.CategoryViewModel

@{
    ViewBag.Title = "editeCategory";
    Layout = "~/Areas/Managerial/Views/Shared/_AdminLayout.cshtml";
}
<span style="color:red">
    @Html.ValidationSummary()
</span>
<section class="course-form">
    @using (Html.BeginForm("UpdateCategory", "Category"))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <h2> <strong>Edit Category</strong></h2>

            <span class="input input--jiro">
                <label class="" for="input-10" style="color:gray">
                    <span class="input__label-content input__label-content--jiro">
                        &nbsp;&nbsp; @Html.HiddenFor(model => model.CategoryID)
                        Category ID
                        &nbsp;&nbsp;&nbsp;
                        @Model.CategoryID
                    </span>
                </label>
            </span>
            <br />
            <span class="input input--jiro">
                <input class="input__field input__field--jiro" type="text" value="@Model.Category_Name" name="Category_Name" id="Category_Name" />
                <label class="input__label input__label--jiro " for="input-10">
                    <span class="input__label-content input__label-content--jiro">
                        Category Name
                        @*<span class="star">@Html.ValidationMessageFor(model => model.Category_Name)</span>*@
                    </span>
                </label>
            </span>
            <div><table>
        <tr>
            <td>
                <button class="send fromedite DeleteCategory" value="@Model.CategoryID"> Delete</button>
            </td>
            <td>  @Html.ActionLink("Back to List", "Index", null, new { @class = "buttonstyle" })</td>
            <td>  @Html.ActionLink("Create new category", "NewCategory", null, new { @class = "buttonstyle" })</td>
            <td>  <input type="submit" class="send" value="Save" /></td>
        </tr>
    </table>
            </div>
    }
 
</section>
<div style="height:200px"></div>

<script src="~/Content/js/jquery-1.11.2.min.js"></script>
<script>

    //----- delete category--------------------------------------------
    $(document).ready(function () {

        $(".DeleteCategory").click(function (a) {

            var caller = $(this);
            var id = $(this).val();
            var x = $(this).hasClass('fromedite');

            if (confirm("Are you sure you want to delete")) {
                $.ajax({
                    type: "POST",
                    url: "/Managerial/Category/DeleteCategory",
                    data: { catID: id },
                    success: function (list) {

                        if (x == true) {
                            location.href = '/Managerial/Category/Index';
                        }
                        else {
                            $('#CategoryContainer').html(list);
                            alert("deleted Successfully");
                        }
                    },
                    error: function () {
                        alert("can't Delet it");
                    }
                });
            }
        })
    })

</script>



